package net;

import java.net.DatagramPacket;
import java.net.DatagramSocket;
import java.net.SocketException;

/**
 *     点对点的传送
 * @author Administrator
 *
 */
public class UDPServer {

	public static void main(String[] args) throws Exception {
	
		
		//用户A
		DatagramSocket socket=new DatagramSocket(8899);
		//空包裹
		byte buf[]=new byte[1000];
		DatagramPacket packet=new DatagramPacket(buf, buf.length);
		//收消息---信息去了buf
		System.out.println("UDP 等消息中。。。");
		socket.receive(packet);
		//拆包
		String info=new String(buf,0,packet.getLength());
		System.out.println("用户A收到消息"+info);
		
		//关闭
		socket.close();
		
		
		
		

	}

}
